<html>
<head><meta charset="utf-8"><title>regexp in rust-analyzer codebase · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/regexp.20in.20rust-analyzer.20codebase.html">regexp in rust-analyzer codebase</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="210110806"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/regexp%20in%20rust-analyzer%20codebase/near/210110806" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Coenen Benjamin <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/regexp.20in.20rust-analyzer.20codebase.html#210110806">(Sep 15 2020 at 10:06)</a>:</h4>
<p>Hello, quick question, is regex allowed in the rust-analyzer codebase ? For example if we want to reformat something like</p>
<div class="codehilite"><pre><span></span><code><span class="p">(</span><span class="w"></span>
<span class="w">    </span><span class="n">a</span>: <span class="kt">i32</span><span class="p">,</span><span class="w"></span>
<span class="w">    </span><span class="n">b</span>: <span class="kt">i32</span>
<span class="p">)</span><span class="w"></span>
</code></pre></div>


<p>to</p>
<div class="codehilite"><pre><span></span><code><span class="p">(</span><span class="n">a</span>: <span class="kt">i32</span><span class="p">,</span><span class="w"> </span><span class="n">b</span>: <span class="kt">i32</span><span class="p">)</span><span class="w"></span>
</code></pre></div>



<a name="210116757"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/regexp%20in%20rust-analyzer%20codebase/near/210116757" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/regexp.20in.20rust-analyzer.20codebase.html#210116757">(Sep 15 2020 at 11:28)</a>:</h4>
<p>We pull in <code>regex</code> via <code>tracing-subscriber</code>, but we don't use them to parse or rewrite source code. I'm a bit confused by your example, would that plug into a LSP formatting request, or is it more of a custom command that you end up needing often?</p>



<a name="210116782"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/regexp%20in%20rust-analyzer%20codebase/near/210116782" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/regexp.20in.20rust-analyzer.20codebase.html#210116782">(Sep 15 2020 at 11:29)</a>:</h4>
<p>There's also SSR, but I don't know if it preserves output whitespace</p>



<a name="210116818"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/regexp%20in%20rust-analyzer%20codebase/near/210116818" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/regexp.20in.20rust-analyzer.20codebase.html#210116818">(Sep 15 2020 at 11:29)</a>:</h4>
<p>Sounds more like something that <code>ra_fmt</code> should handle once it exists</p>



<a name="210117480"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/regexp%20in%20rust-analyzer%20codebase/near/210117480" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/regexp.20in.20rust-analyzer.20codebase.html#210117480">(Sep 15 2020 at 11:39)</a>:</h4>
<p>And that's not valid syntax, is it? We don't handle it very well.</p>
<p><a href="user_uploads/4715/PuyvXWe0xfjgCPKZbRFauPLg/image.png">image.png</a></p>
<div class="message_inline_image"><a href="user_uploads/4715/PuyvXWe0xfjgCPKZbRFauPLg/image.png" title="image.png"><img src="user_uploads/4715/PuyvXWe0xfjgCPKZbRFauPLg/image.png"></a></div>



<a name="210118849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/regexp%20in%20rust-analyzer%20codebase/near/210118849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Coenen Benjamin <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/regexp.20in.20rust-analyzer.20codebase.html#210118849">(Sep 15 2020 at 11:55)</a>:</h4>
<p>Sorry for delay, in fact it's to fix this issue <a href="https://github.com/rust-analyzer/rust-analyzer/issues/6002">https://github.com/rust-analyzer/rust-analyzer/issues/6002</a></p>



<a name="210119438"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/regexp%20in%20rust-analyzer%20codebase/near/210119438" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lukas Wirth <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/regexp.20in.20rust-analyzer.20codebase.html#210119438">(Sep 15 2020 at 12:02)</a>:</h4>
<p>Shouldn't it be enough to reconstruct the function signature with just your usual expected whitespaces between the parameters? Regex seems a bit too much for this in my eyes, though that might be personal preference <span aria-label="sweat smile" class="emoji emoji-1f605" role="img" title="sweat smile">:sweat_smile:</span></p>



<a name="210124198"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/regexp%20in%20rust-analyzer%20codebase/near/210124198" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Coenen Benjamin <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/regexp.20in.20rust-analyzer.20codebase.html#210124198">(Sep 15 2020 at 12:51)</a>:</h4>
<p>Yes maybe it could be an idea, I will think about that and try to find better solution. IMO regex is clearly too much, due to this question and to have some other solutions. Thanks for your help :)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>